package com.mk.admin.controller;

import com.alibaba.fastjson2.JSONObject;
import com.mk.admin.model.ResultDto;
import com.mk.admin.model.query.*;
import com.mk.admin.model.vo.*;
import com.mk.admin.util.HttpTool;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/a/adm/check")
@Api(tags = "门诊类", value = "针对患者自己检查查询")
public class CheckController {
    @PostMapping("/checkTestProject")
    @ApiOperation(value = "com_0015获取检查检验项目", tags = "患者检查")
    public ResultDto checkTestProject(@RequestBody CheckTestProjectQuery query) {
        JSONObject jsonObject = HttpTool.postJson("com_0015", query);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @PostMapping("/checkTestProjectDetail")
    @ApiOperation(value = "com_0016获取检查检验项目明细", tags = "患者检查")
    public ResultDto checkTestProjectDetail(@RequestBody CheckTestProjectDetailQuery query) {
        JSONObject jsonObject = HttpTool.postJson("com_0016", query);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @PostMapping("/signIn")
    @ApiOperation(value = "opt_0034检查检验签到", tags = "患者检查", notes = "检查检验签到")
    public ResultDto signIn(@RequestBody CheckSignInVo vo) {
        JSONObject jsonObject = HttpTool.postJson("opt_0034", vo);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }


    @PostMapping("/departmentNum")
    @ApiOperation(value = "opt_0035检查科室号源查询", tags = "患者检查", notes = "检查科室号源查询")
    public ResultDto departmentNum(@RequestBody CheckDepartmentNumQuery query) {
        JSONObject jsonObject = HttpTool.postJson("opt_0035", query);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }


    @PostMapping("/consultingRoomNum")//诊室号源
    @ApiOperation(value = "opt_0036检查诊室号源分时查询", tags = "患者检查", notes = "检查诊室号源分时查询")
    public ResultDto selectConsultingRoomNum(@RequestBody CheckConsultingRoomNumQuery query) {
        JSONObject jsonObject = HttpTool.postJson("opt_0036", query);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @PostMapping("/consultingRoomReserve")
    @ApiOperation(value = "opt_0037检查诊室预约", tags = "患者检查", notes = "检查诊室预约")
    public ResultDto consultingRoomReserve(@RequestBody CheckConsultingRoomReserveVo vo) {
        JSONObject jsonObject = HttpTool.postJson("opt_0037", vo);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @SuppressWarnings("all")
    @PostMapping("/consultingRoomReserveCancel")
    @ApiOperation(value = "opt_0038检查诊室预约取消", tags = "患者检查", notes = "检查诊室预约取消")
    public ResultDto consultingRoomReserveCancel(@RequestBody CheckConsultingRoomReserveCancelVo vo) {
        JSONObject jsonObject = HttpTool.postJson("opt_0038", vo);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }


    @PostMapping("/testReserve")
    @ApiOperation(value = "opt_0054检查检验预约", tags = "患者检查", notes = "检查检验预约")
    public ResultDto testReserve(@RequestBody CheckTestReserveVo vo) {
        JSONObject jsonObject = HttpTool.postJson("opt_0054", vo);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @PostMapping("/testReserveCancel")
    @ApiOperation(value = "opt_0055检查检验预约取消", tags = "患者检查", notes = "检查检验预约取消")
    public ResultDto testReserveCancel(@RequestBody CheckTestReserveCancelVo vo) {
        JSONObject jsonObject = HttpTool.postJson("opt_0055", vo);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @SuppressWarnings("all")
    @PostMapping("/consultingRoomUnReserve")
    @ApiOperation(value = "opt_0039查询患者未预约检查单", tags = "患者检查", notes = "获取患者未预约的检查检验信息")
    public ResultDto selectConsultingRoomUnReserve(@RequestBody CheckConsultingRoomUnReserveQuery query) {
        JSONObject jsonObject = HttpTool.postJson("opt_0039", query);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }


    @PostMapping("/consultingRoomReserveSuccess")
    @ApiOperation(value = "opt_0040查询患者已预约检查单", tags = "患者检查", notes = "查询患者已预约检查单")
    public ResultDto selectConsultingRoomReserveSuccess(@RequestBody CheckConsultingRoomReserveSuccessQuery query) {
        JSONObject jsonObject = HttpTool.postJson("opt_0040", query);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }


    @PostMapping("/medicalRecord")
    @ApiOperation(value = "opt_0051患者病历查询", tags = "患者检查", notes = "查询患者门急诊病历详情（日期降序排序）")
    public ResultDto selectMedicalRecord(@RequestBody CheckMedicalRecordQuery query) {
        JSONObject jsonObject = HttpTool.postJson("opt_0051", query);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }


    @PostMapping("/diagnosis")// 诊断
    @ApiOperation(value = "opt_0052患者诊断查询", tags = "患者检查", notes = "获取患者的诊断信息（日期降序排序）")
    public ResultDto selectDiagnosis(@RequestBody CheckDiagnosisQuery query) {
        JSONObject jsonObject = HttpTool.postJson("opt_0052", query);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @PostMapping("/projectApply")
    @ApiOperation(value = "opt_0085检查项目申请", tags = "患者检查", notes = "检查项目开单申请")
    public ResultDto checkProjectApply(@RequestBody CheckProjectApplyVo vo) {
        JSONObject jsonObject = HttpTool.postJson("opt_0085", vo);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @PostMapping("/testProjectApply")
    @ApiOperation(value = "opt_0086检验项目申请", tags = "患者检查", notes = "检验项目开单申请")
    public ResultDto checkTestProjectApply(@RequestBody CheckTestProjectApplyVo vo) {
        JSONObject jsonObject = HttpTool.postJson("opt_0086", vo);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @PostMapping("/newBabyRecord")
    @ApiOperation(value = "opt_0096查询新生儿记录", tags = "患者检查", notes = "查询新生儿记录")
    public ResultDto selectNewBabyRecord(@RequestBody CheckNewBabyRecordQuery query) {
        JSONObject jsonObject = HttpTool.postJson("opt_0096", query);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @PostMapping("/skinTest")
    @ApiOperation(value = "opt_0097写入皮试记录", tags = "患者检查", notes = "写入皮试记录")
    public ResultDto skinTest(@RequestBody CheckSkinTestVo vo) {
        JSONObject jsonObject = HttpTool.postJson("opt_0097", vo);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @PostMapping("/cancelTestProjectApply")
    @ApiOperation(value = "opt_0098取消检查检验申请", tags = "患者检查", notes = "取消检查检验申请")
    public ResultDto cancelTestProjectApply(@RequestBody CheckCancelTestProjectApplyVo vo) {
        JSONObject jsonObject = HttpTool.postJson("opt_0098", vo);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @PostMapping("/canNextDiagnosis")
    @ApiOperation(value = "opt_0099患者复诊校验查询", tags = "患者检查", notes = "患者复诊校验查询，查询患者可否进行复诊")
    public ResultDto selectCanNextDiagnosis(@RequestBody CheckCanNextDiagnosisQuery query) {
        JSONObject jsonObject = HttpTool.postJson("opt_0099", query);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @PostMapping("/applyList")
    @ApiOperation(value = "opt_0100检查申请单列表查询", tags = "患者检查", notes = "检查申请单列表查询")
    public ResultDto selectApplyList(@RequestBody CheckApplyListQuery query) {
        JSONObject jsonObject = HttpTool.postJson("opt_0100", query);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @PostMapping("/applyListDetail")
    @ApiOperation(value = "opt_0101检查申请单详情查询", tags = "患者检查", notes = "检查申请单详情查询")
    public ResultDto selectApplyListDetail(@RequestBody CheckApplyListDetailQuery query) {
        JSONObject jsonObject = HttpTool.postJson("opt_0101", query);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @PostMapping("/canReserveDate")
    @ApiOperation(value = "opt_0102检查可预约日期查询", tags = "患者检查", notes = "检查可预约日期查询")
    public ResultDto selectCanReserveDate(@RequestBody CheckCanReserveDateQuery query) {
        JSONObject jsonObject = HttpTool.postJson("opt_0102", query);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @PostMapping("/canReserveAreaDate")
    @ApiOperation(value = "opt_0103可预约时段查询", tags = "患者检查", notes = "可预约时段查询")
    public ResultDto selectCanReserveAreaDate(@RequestBody CheckCanReserveAreaDateQuery query) {
        JSONObject jsonObject = HttpTool.postJson("opt_0103", query);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @PostMapping("/reserve")
    @ApiOperation(value = "opt_0104检查确定预约", tags = "患者检查", notes = "检查确定预约")
    public ResultDto reserve(@RequestBody CheckReserveVo vo) {
        JSONObject jsonObject = HttpTool.postJson("opt_0104", vo);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @PostMapping("/cancelReserve")
    @ApiOperation(value = "opt_0105检查取消预约", tags = "患者检查", notes = "检查取消预约")
    public ResultDto cancelReserve(@RequestBody CheckCancelReserveVo vo) {
        JSONObject jsonObject = HttpTool.postJson("opt_0105", vo);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @PostMapping("/theDayCanReportType")
    @ApiOperation(value = "opt_0106当日可报到检查类型查询", tags = "患者检查", notes = "查询用户已经预约在当天，但还没报道的检查类型+预约号列表")
    public ResultDto selectTheDayCanReportType(@RequestBody CheckTheDayCanReportTypeQuery query) {
        JSONObject jsonObject = HttpTool.postJson("opt_0106", query);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @PostMapping("/reportInfo")
    @ApiOperation(value = "opt_0107检查记录用户报到信息", tags = "患者检查", notes = "记录用户报到信息")
    public ResultDto selectReportInfo(@RequestBody CheckReportInfoQuery query) {
        JSONObject jsonObject = HttpTool.postJson("opt_0107", query);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @PostMapping("/theDayReportCompleted")
    @ApiOperation(value = "opt_0108查询当天已报到列表", tags = "患者检查", notes = "用户通过申请单查询检查预约详细信息")
    public ResultDto selectTheDayReportCompleted(@RequestBody CheckTheDayReportCompletedQuery query) {
        JSONObject jsonObject = HttpTool.postJson("opt_0108", query);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @PostMapping("/writeBabyBodySign")
    @ApiOperation(value = "opt_0109写入生命体征数据", tags = "患者检查", notes = "写入生命体征数据")
    public ResultDto writeBabyBodySign(@RequestBody CheckWriteBabyBodySignVo vo) {
        JSONObject jsonObject = HttpTool.postJson("opt_0109", vo);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @PostMapping("/invoiceByReceiptNo")
    @ApiOperation(value = "opt_0110根据收据号查询HIS电子发票详细", tags = "患者检查", notes = "根据收据号查询HIS电子发票详细")
    public ResultDto selectInvoiceByReceiptNo(@RequestBody CheckInvoiceByReceiptNoQuery query) {
        JSONObject jsonObject = HttpTool.postJson("opt_0110", query);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @PostMapping("/signPatientInfo")
    @ApiOperation(value = "opt_0111签约病人信息查询", tags = "患者检查", notes = "签约病人信息查询")
    public ResultDto selectSignPatientInfo(@RequestBody CheckSignPatientInfoQuery query) {
        JSONObject jsonObject = HttpTool.postJson("opt_0111", query);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @PostMapping("/serviceInfo")
    @ApiOperation(value = "opt_0112服务信息查询", tags = "患者检查", notes = "服务信息查询")
    public ResultDto selectServiceInfo(@RequestBody CheckServiceInfoQuery query) {
        JSONObject jsonObject = HttpTool.postJson("opt_0112", query);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }

    @PostMapping("/canReturnFee")
    @ApiOperation(value = "opt_0114查询HIS可退费信息", tags = "患者检查", notes = "查询HIS可退费信息")
    public ResultDto selectCanReturnFee(@RequestBody CheckCanReturnFeeQuery query) {
        JSONObject jsonObject = HttpTool.postJson("opt_0114", query);
        Object result = jsonObject.get("result");
        if (result != null && !"".equals(result)) {
            return ResultDto.data(result);
        }
        return ResultDto.data(jsonObject);
    }


}
